<?php

    class qa_hot_questions {

        function allow_template($template)
        {

            $allow=true;
            
            return $allow;
        }

        function allow_region($region)
        {
            return ($region=='side');
        }

        function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
        {
            $temp = qa_db_query_sub(
				'SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$ ORDER BY views LIMIT 0, 10',
                'Q'
			);

            $max = mysql_num_rows($temp);
            if(!$max) return;
            
            $themeobject->output('<h2>'.qa_opt('hot_question_title').'</h2>');
			while($row = mysql_fetch_assoc($temp)){
				if (is_array($row)) {
                    $votes = (int)$row['netvotes'];
                    $answers = (int)$row['acount'];
                    $themeobject->output('
						<div class="hot-question">
							<div class="hot-question-vote">'.$votes.'</div>
							<div class="question-title">
							    <h3><a href="'.qa_path_html(qa_q_request($row['postid'], $row['title'])).'">'.$row['title'].'</a></h3>
							    <div class="answer-question">'.$answers.'</div> Câu trả lời
							</div>
						</div>

					');
                }
			}
        }
    };


/*
    Omit PHP closing tag to help avoid accidental output
*/
